import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;
class a4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] arr=new int[10];
        for(int i=0;i<10;i++){
            arr[i]=in.nextInt();
        }
        ArrayList<Integer> left=new ArrayList();
        ArrayList<Integer> right=new ArrayList();
//        int flag=1;
        for(int i=9;i>=0;i--){
            while(arr[i]>0){
                if(left.size()==0){
                    left.add(i);
                    arr[i]--;
                    continue;
                }
                if(right.size()==0){
                    right.add(i);
                    arr[i]--;
                    continue;
                }
                if(checkIt(left,right)){
                    right.add(i);
                    arr[i]--;
                }else{
                    left.add(i);
                    arr[i]--;
                }
            }
        }
//        System.out.println(getString(left));
//        System.out.println(getString(right));
        getResult(left,right);
    }
 
    public static void getResult(ArrayList<Integer> left,ArrayList<Integer> right){
        BigInteger l1=new BigInteger(getString(left));
        BigInteger l2=new BigInteger(getString(right));
        BigInteger ret=l1.multiply(l2);
        System.out.println(ret);
    }
 
    public static String getString(ArrayList<Integer> arr){
        StringBuilder ret=new StringBuilder();
        for(Integer e:arr){
            ret.append(e);
        }
        return ret.toString();
    }
    //true 下一个给right
    //false 下一个给left
    public static boolean checkIt(ArrayList<Integer> left,ArrayList<Integer> right){
        if(left.size()>right.size()) return true;
        if(right.size()>left.size()) return false;
        for(int i=0;i<left.size();i++){
            if(left.get(i).equals(right.get(i))) continue;
            return left.get(i) > right.get(i);
        }
        return true;
    }
}